package leetcode.秋招.京东;

import java.util.HashMap;
import java.util.Scanner;

/**
 * @author ：zsy
 * @date ：Created 2021/8/21 19:55
 * @description：
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        in.nextLine();
        String ss = in.nextLine();
        int a1 = 0, a2 = 0;
        HashMap<String, Integer> map = new HashMap<>();
        int[] pres = new int[N];
        for (int i = 0; i < N; i++) {
            if (ss.charAt(i) == '0') a1++;
            else a2++;
            int x = method(a1, a2);
            int a = a1 / x, b = a2 / x;
            String temp = a + "-" + b;
            map.put(temp, map.getOrDefault(temp, 0) + 1);
            pres[i] = map.get(temp);
        }
        for (int i = 0; i < N; i++) {
            System.out.print(pres[i] + "");
        }
        System.out.println();
    }

    private static int method(int x, int y) {
        if (y == 0) return x;
        else
            return method(y, x % y);
    }
}
